{extend name="public:layout" /}

{block name="title"}
    <title>{:site('siteName')}-出售记录</title>
{/block}

{block name="css"}
    <style>
        .sell-tab { height: 40px; border-bottom: 1px solid #e2e2e2 }
        .sell-tab li { width: 50%; float: left; text-align: center; line-height: 40px; }
        .sell-tab .this { color: #009688; border-bottom: 3px solid #5FB878; margin-bottom: -3px;}
    </style>
{/block}

{block name="content"}
    <ul class="sell-tab">
        <li><a href="/sell">申请挂售</a></li>
        <li class="this">挂售记录</li>
    </ul>
    <div class="layui-tab-content">
        <blockquote class="layui-elem-quote layui-quote-nm">注意：超时未确认，系统将会自动确认已完成，如还未收到款，请在超时之前联系客服延长超时时间并及时和接单人沟通。</blockquote>
        <div class="account_li">
            <ul>
                {volist name="list" id="v"}
                <li>
                    <p><span>时间</span><br />{:date('Y-m-d',$v['time'])}</p>
                    <p><span>超时</span><br />{:date('H:i:s',$v['timeout'])}</p>
                    <p><span>接单人手机</span><br />{:get_userinfo($v['agent_id'],'mobile')}</p>
                    <p><span>申请</span> <br />{$v['money'] + $v['fee']}</p>
                    <p><span>手续</span><br />{$v.fee}</p>
                    <p><span>应付</span><br />{$v.money}</p>
                    <p>
                        <span>状态</span><br />
                        {eq name="v.status" value="0"}出售中{/eq}
                        {eq name="v.status" value="1"}已接单{/eq}
                        {eq name="v.status" value="2"}已支付{/eq}
                        {eq name="v.status" value="3"}已完成{/eq}
                        {eq name="v.status" value="4"}已撤销{/eq}
                    </p>
                    <p><span>备注</span><br />{$v.note}</p>
                    <p>
                        <span>操作</span><br />
                        {eq name="v.status" value="0"}
                            <button class="layui-btn layui-btn-mini layui-btn-red revoke" sell_id="{$v.id}">撤销</button>
                        {/eq}
                        {eq name="v.status" value="2"}
                            <button class="layui-btn layui-btn-mini layui-btn-main confirm" sell_id="{$v.id}">确认</button>
                        {/eq}
                    </p>
                  </li>
                  {/volist}
            </ul>
        </div>

        <div class="page">
            {$list->render()}
        </div>
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        layui.use(['form','layer'], function(){
            var $ = layui.jquery;
            var form = layui.form();
            var layer = layui.layer;
            //撤销
            $('.revoke').click(function() {
                var sell_id = $(this).attr('sell_id');
                checkPwd(function(pwd){
                    layer.confirm('确定撤销挂售', {
                        btn: ['确定', '取消'],
                        icon: 3
                    }, function(index) {
                        layer.close(index);
                        $.post('{:url("index/sell/revoke")}', {id: sell_id,pwd:pwd}, function(res) {
                            if(res.success == 1){
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function() {
                                    location.reload();
                                });
                            }else{
                                layer.msg(res.msg);
                            }
                        });
                    });
                });
                return false;
            });
            //确认
            $('.confirm').click(function(){
                var sell_id = $(this).attr('sell_id');
                checkPwd(function(pwd){
                    layer.confirm('确认已收款', {
                        btn: ['确认', '取消'],
                        icon: 3
                    }, function(index) {
                        layer.close(index);
                        $.post('{:url("index/sell/confirm")}', {id: sell_id,pwd:pwd}, function(res) {
                            if(res.success == 1){
                                layer.msg(res.msg, {
                                    time: 1000
                                }, function() {
                                    location.reload();
                                });
                            }else{
                                layer.msg(res.msg);
                            }
                        });
                    });
                });
                return false;
            });
        });
    </script>
{/block}
